import axios from 'axios';
import { AnyObject } from '@/types/global';

const url = '/adminapi/systemFile/';

export interface DataState {
  name: string;
  filesize: string;
  modif: string;
  perms: string;
  owner: string[];
}

export interface QueryParams extends Partial<DataState> {
  path: string;
}

export interface DataListRes {
  data: DataState[];
  breadcrumbs?: string[];
  path?: string;
  'all_files_size'?: number;
  'num_files'?: number;
  'num_folders'?: number;
  'partition_size'?: number;
  'free_of_size'?: number;
}

/**
 * 列表
 */
export function apiList(params?: QueryParams) {
  return axios.get<DataListRes>(`${url}index`, { params });
}

/**
 * 操作
 */
export function apiHandle(params: AnyObject) {
  return axios.get(`${url}handle`, { params });
}
